<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>第8节课</title>
		<style type="text/css">
			* {
				padding: 0;
				margin: 0;
			}

			.container {
				width: 100vw;
				height: 100vh;
				display: flex;
				/*
		     * 将边框设置在中间
		     */
				align-items: center;
				justify-content: center;
			}

			canvas {
				width: 500px;
				height: 500px;
				border: 1px solid #333333;
			}
		</style>
	<body>
		<!-- <img src="../img/img.png" id="img"> -->
		<div class="container">
			<canvas id="canvas" width="500px" height="500px"></canvas>
			<div><input type="button" name="" id="right-btn" value="向右移动" />
				<input type="button" name="" id="left-btn" value="向左移动" />
				<input type="button" name="" id="down-btn" value="向下移动" />
				<br>
				<input type="button" name="" id="off-btn" value="向上移动" />
				<input type="button" name="" id="move" value="清除" /></div>

		</div>
	</body>
	<script>
		window.onload = function() {
			let yCanvas = document.getElementById('canvas');
			console.dir(yCanvas);
			let yPen = yCanvas.getContext("2d");

			// var image = new Image();
			// image.src = './img.png'

			// image.onload =function(){
			// 	open.drawImage(Image,0,0,500,500)
			// 	var data =ImageData.data
			// 	console.dir(data)

			// 	document.getElementById('light').onclick =function(){
			// 		let light =parseFloat(document.getElementById('nu-light').value)
			// 		console.dir(light)
			// 		for(var i=0;i<data.length;i+=4){
			// 			//                 data[i+0]+=light
			// 			//                 data[i+1]+=light
			// 			//                 data[i+2]+=light
			// 			data[i+3]*=light
			// 		}
			// 		//渲染像素
			// 		//putImageData(imageData,x,y)
			// 		open.putImageData(ImageData,0,0)
			// 	}
			// 	creatrImageData(width,height);

			//part2
			var imageData = open.creatrImageData(100, 100);
			var data = imageData.data

			for (var i = 0; i < data.length; i += 4) {
				data[i + 0] = 0
				data[i + 1] = 0
				data[i + 2] = 0
				data[i + 3] = 255
			}
			open.putImageData(imagedata, 0, 0)
		}
		}
	</script>
</html>
